Skip to content

[AE-158] Add Github Actions [draft] #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 1, 2023
Merged

Conversation

aliphys
Copy link
Contributor

@aliphys aliphys commented Aug 31, 2023

This PR adds workflows for automated compilance checks.

  • 🔍 Checks we meet library specifications
  • ✅ Check sketches compile on designated platforms
  • 🔠 Spelling is correct

@aliphys aliphys added the type: enhancement Proposed improvement label Aug 31, 2023
@aliphys aliphys self-assigned this Aug 31, 2023
@aliphys aliphys force-pushed the aliphys/AddGHActions branch 2 times, most recently from 3444673 to 2f3eddd Compare August 31, 2023 07:36
Comment on lines 42 to 45
type: arduino:mbed_portenta
- fqbn: arduino:renesas_portenta:portenta_c33
type: renesas_portenta
- fqbn: arduino:mbed:opta
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type: arduino:mbed_portenta
- fqbn: arduino:renesas_portenta:portenta_c33
type: renesas_portenta
- fqbn: arduino:mbed:opta
platforms: |
- name: arduino:mbed_portenta
- fqbn: arduino:renesas_portenta:portenta_c33
platforms: |
- name: arduino:renesas_portenta
- fqbn: arduino:mbed_opta:opta
platforms: |
- name: arduino:mbed_opta
  • Correct platform dependency definitions
  • Use the family-specific arduino:mbed_opta platform instead of the deprecated arduino:mbed in order to get the latest version of the platform.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The definition schema I used here - with the type: key - is similar to what is currently in use inside other Arduino libraries such as the Arduino_ESP32_OTA.

Do we have a reference regarding the platform definitions? I could not find type: mentioned here as deprecated or otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to what is currently in use inside other Arduino libraries such as the Arduino_ESP32_OTA.

There wasn't any benefit from the use of this approach in the Arduino_ESP32_OTA library so that workflow isn't a good reference. A better example of the use of this approach is in these workflows:

The jobs.<job_id>.strategy.matrix workflow key is used to create multiple variants of the workflow job. In the case of the sketch compilation workflows, we use a separate job for each of the boards we want to compile the sketches for.

The job is configured differently for each board. In the most simple case, only the FQBN is different from one matrix job to another, but often we have other adjustments (such as the platform dependency). You can make those adjustments directly in the matrix element:

matrix:
  board:
    - fqbn: arduino:avr:uno
      platforms: |
        - name: arduino:avr
      libraries: |
        - name: SomeAVRLib

But in cases where the same configuration is needed for a multiple boards, this results in code duplication in the workflow.

For example, notice that the same platform and library dependency configurations must be duplicated multiple times in this matrix:

matrix:
  board:
    - fqbn: arduino:avr:leonardo
      platforms: |
        - name: arduino:avr
      libraries: |
        - name: SomeAVRLib
    - fqbn: arduino:avr:mega
      platforms: |
        - name: arduino:avr
      libraries: |
        - name: SomeAVRLib
    - fqbn: arduino:avr:uno
      platforms: |
        - name: arduino:avr
      libraries: |
        - name: SomeAVRLib
    - fqbn: arduino:samd:mkrzero
      platforms: |
        - name: arduino:samd
      libraries: |
        - name: SomeSAMDLib
    - fqbn: arduino:samd:arduino_zero_edbg
      platforms: |
        - name: arduino:samd
      libraries: |
        - name: SomeSAMDLib

If we want to follow the software development best practice of "DRY", we can instead add an object for the relevant attribute of the boards to the matrix elements then use the jobs.<job_id>.strategy.matrix.include workflow key to apply the shared configuration to each of the jobs that have that object set to a given value:

matrix:
  board:
    - fqbn: arduino:avr:leonardo
      type: avr
    - fqbn: arduino:avr:mega
      type: avr
    - fqbn: arduino:avr:uno
      type: avr
    - fqbn: arduino:samd:mkrzero
      type: samd
    - fqbn: arduino:samd:arduino_zero_edbg
      type: samd

  include:
    - board:
        type: avr
      platforms: |
        - name: arduino:avr
      libraries: |
        - name: SomeAVRLib
    - board:
        type: samd
      platforms: |
        - name: arduino:samd
      libraries: |
        - name: SomeSAMDLib

Do we have a reference regarding the platform definitions?

https://github.com/arduino/compile-sketches#platforms

I could not find type: mentioned here

That is because it is general purpose GitHub Actions workflow code; nothing specific to the arduino/compile-sketches action. The type key name is only an arbitrary identifier. You could use foobar instead and it will work just the same.

If you want to understand better, I recommend you create a throwaway repository and experiment with some simple "hello world" type workflows. For example:

on:
  push:

jobs:
  hello:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        some-matrix-object-key:
          - some-matrix-element-object-key: This is the value of some matrix element object for the 1st element
            some-matrix-element-object-include-key: foo
          - some-matrix-element-object-key: This is the value of some matrix element object for the 2nd element
            some-matrix-element-object-include-key: foo
          - some-matrix-element-object-key: This is the value of some matrix element object for the 3rd element
            some-matrix-element-object-include-key: bar
          - some-matrix-element-object-key: This is the value of some matrix element object for the 4th element
            some-matrix-element-object-include-key: bar

        include:
          - some-matrix-object-key:
              some-matrix-element-object-include-key: foo
            some-include-element-object-key: This is the value of some include element object for the matrix elements with value foo
          - some-matrix-object-key:
              some-matrix-element-object-include-key: bar
            some-include-element-object-key: This is the value of some include element object for the matrix elements with value bar

    steps:
      - run: |
          echo "The value of some matrix element object is: ${{ matrix.some-matrix-object-key.some-matrix-element-object-key }}"
          echo "The value of some include element object is: ${{ matrix.some-include-element-object-key }}"

The workflow above will work exactly the same if you changed the arbitrary key name some-matrix-element-object-include-key to type or foobar or amazing-key-name.

@aliphys aliphys force-pushed the aliphys/AddGHActions branch from 2f3eddd to 9934b7c Compare September 1, 2023 09:38
@aliphys
Copy link
Contributor Author

aliphys commented Sep 1, 2023

Unable to compile library examples due to

Arduino_POSIXStorage library is a dependency of this repo. But the GitHub action cannot find it.

Error: Library source path: https:/github.com/arduino-libraries/Arduino_POSIXStorage doesn't exist
Error: Process completed with exit code 1.

@cristidragomir97 cristidragomir97 merged commit b43fa3f into main Sep 1, 2023
@aliphys aliphys deleted the aliphys/AddGHActions branch September 1, 2023 11:39
@per1234 per1234 added the topic: infrastructure Related to project infrastructure label Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: infrastructure Related to project infrastructure type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants